package Soundsystem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Grup:Soundsystem
 * @Auther:cola
 * @Data:2021/4/17-2021-04-16:43
 * @version:1.0
 */
@Component
public class CDPlayer {
    @Autowired
    private Power power;
    @Autowired(required = false)
    private CompactDisc cd;
    /*@Autowired
    public void setPower(Power power) {
        this.power = power;
        System.out.println("调用setPower.....");
    }
    @Autowired
    public void setCd(CompactDisc cd) {
        this.cd = cd;
        System.out.println("调用setCd.....");
    }*/

    public CDPlayer() {
        super();
        System.out.println("CDPlayer无参构造函数");
    }
    /*@Autowired
    public CDPlayer(CompactDisc cd) {
        this.cd = cd;
        System.out.println("CDPlayer的有参构造函数!");
    }*/
    /*@Autowired
    public CDPlayer(Power power, CompactDisc cd) {
        this.power = power;
        this.cd = cd;
        System.out.println("CDPlayer的多参数构造函数");
    }*/
   /* @Autowired
    public void prepare(CompactDisc cd,Power power){
        this.cd=cd;
        this.power=power;
        System.out.println("调用prepare方法.......");
    }*/

    public void play(){
        power.supply();
        if (cd!=null){
            cd.play();
        }

    }
}
